
#include <stdio.h>
#include <math.h>
int maxChunksToSorted(int* arr, int arrSize) {
    int m = 0;
    int res = 0;
    for (int i = 0; i < arrSize; ++i) {
        m = fmax(m, arr[i]);
        if (m == i) {
            res++;
        }
    }
    return res;
}

int main()
{
    int test[5] = {4,3,2,1,0};
    int ret = maxChunksToSorted(test, 5);
    printf("%d", ret);
}